<?php
namespace app\business\model;
use think\Model;
use think\Db;

class BusinessLogin extends Model
{
    protected $table = 'business_login';

    public function login($data){

        $user=Db::name('login')->where('username','=',$data['username'])->find();

        if($user){
            if(password_verify($data['password'],$user['password'])){
                 //var_dump($user);die;
               $d = db('info')->where('business_id',$user['business_id'])->find();

               if ($d['business_trial'] !== 2) {
                   return 4;
               }

                session('business_id',$user['business_id']);
                session('username',$user['username']);
				session('business_name',$d['business_name']);
                session('uid',$user['id']);

                return 3; //信息正确
            }else{
                return 2; //密码错误
            }
        }else{
            return 1; //用户不存在
        }
    }
}